<%-- 
    Document   : AddCube
    Created on : Sep 30, 2011, 10:23:49 PM
    Author     : KimberlyJordan
--%>

<%@page import="EntityState.PartnerAccountState"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List, java.util.ArrayList"%>
<%@page import="java.util.ArrayList, BusinessLogic.Constants" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>FoodSage Partner Administration</title>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery-1.6.4.min.js"></script>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery.form.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/fieldsetCollapse.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/tcubmenu.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/accordion.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/scroller.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/Utilities.js"></script>

        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/gridsys.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/reset1.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcube.css" />
        <link href="../TransactWeb/css/gridsys.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcubaccd.css" />
        <script type="text/javascript">
            // Check Session to show relevant menus
            // Be sure to import Utilities.js in the script file	and declare partnerMenu as a servelet element
            window.onload = showPage('partnerMenu', 'leftnav');

            // If not logged in, use : 
            //window.onload = showPage('topMenu', 'topmenu');
            //IF logged in use : 
            window.onload = showPage('topMenulogout', 'topmenu');
          
            //welcome msg
            window.onload = showPage('welcomeMenu','welcome');
            
            //footer
            window.onload = showPage('partnerFooter','footer');
            
            $(document).ready(function() {
                $.ajax({
                    type: "GET",
                    cache: false,
                    url:  "GetInfo",
                    data: {
                        action: <%= Constants.GET_LIST_OF_PARTNER_CATEGORIES%>
                    },
                    success: function(response) { 
                        var categoryIDs = [];
                        var itemIDs     = [];
                        categoryIDs.push('<option value="0">Select a Category</option>');
                        itemIDs.push('<option>Select an Item</option>');
                        $(response).find("category").each(function() {
                            // Get category info
                            var id = $(this).find("catID").text();
                            var name = $(this).find("catName").text();
                            categoryIDs.push('<option value="', 
                            id, '">', 
                            name, '</option>');
                            itemIDs.push('<option disabled="true" style="font-weight:bold;"><b>', name, '</b></option>', '<option disabled="true"/>');
                            // Get items in the category
                            $(this).find("item").each(function() {
                                var id = $(this).find("itemID").text();
                                var name = $(this).find("itemName").text();
                                itemIDs.push('<option value="', id, '">', name, '</option>');
                            });
                            itemIDs.push('<option disabled="true"/>');
                        });
                        $("#categoryID").html(categoryIDs.join(''));
                        $("#subItem").html(itemIDs.join(''));
                    }, 
                    dataType: "xml"
                });
                
                // bind 'myForm' and provide a simple callback function
                $('#addCubeForm').ajaxForm({
                    success: function(response){
                        var status = $(response).find("status").text();
                        $("#addCubeStatus").html(status);
                    },
                    dataType: "xml"
                });
                
            }); 
        </script>
    </head>
    <body>
        <div class="container_12">
            <!-- Header Nav -->   
            <div class="grid_3"><img src="../TransactWeb/img/reservation/foodsglogo.png" width="146" height="178" /></div>
            <div class="grid_9 nav">
                <div id="topmenu"></div>
            </div>
            <div class="grid_12">
                <hr size="3" color="#CC6600" />
            </div>
            <!-- Welcome Message -->
            <div class="grid_12 welcome">
                <div id="welcome"></div>
            </div>
            <!-- End Welcome Message-->

            <!-- End of Header Nav -->
            <!-- Menu / Planner -->
            <div class="grid_4">
                <div id="leftnav"></div>
            </div>
            <!--End Menu/ Planner -->
            <!-- Content -->
            <div class="grid_8 content">
                <!-- Content Header -->

                <table width="600" border="0">
                    <tr>
                        <td class="content_title">Cube Management</td>
                    </tr>
                    <tr>
                        <td class="content_purpose">Add Cube</td>
                    </tr>
                </table>
                <!-- End Content Header-->
                <!-- Form -->
                <div id="addCubeStatus" style="padding-left: 10px; color: #f7964f; margin-bottom: 10px;"></div>
                <form action="AddCubeStatus" id="addCubeForm" method="post" encType="multipart/form-data" >

                    <table width="600" border="0" class="formstyle">
                        <tr>
                            <td>Cube Name</td>
                            <td><input type="text" name="name" id="name" /></td>
                        </tr>
                        <tr>
                            <td>Cube Description</td>
                            <td><input type="text" name="description" id="description" /></td>
                        </tr>
                        <%
                            for (int i = 1; i < Constants.FILE_MAX_NUM_OF_ITEM_PICTURE + 1; i++) {
                        %>
                        <tr>
                            <td>Picture</td>
                            <td><input type="file" name="<%= i%>"  /></td>
                        </tr>
                        <tr>
                            <td>Picture Description</td>
                            <td><input type="text" name="<%= "description" + i%>" /></td>
                        </tr>
                        <%
                            }
                        %>
                        <tr>
                            <td width="194">Item Category</td>
                            <td><select name="categoryID" id="categoryID"></select></td>
                        </tr>
                        <tr>
                            <td width="194">Sub Items</td>
                            <td><select name="subItem" id="subItem" multiple="true" size="10"></select></td> 
                        </tr>
                        <tr>
                            <td>Discount</td>
                            <td><input type="text" name="discount" id="discount" /></td>
                        </tr>
                        <tr>
                            <td>Price</td>
                            <td><input type="text" name="price" id="price" /></td>
                        </tr>
                        <tr>
                            <td>Additional Loyalty Point</td>
                            <td><input type="text" name="additionalLoyaltyPoint" /></td>
                        </tr>
                        <tr>
                            <td>Maximum Buyer Limit</td>
                            <td><input type="text" name="maxNumberOfBuyers" /></td>
                        </tr>
                        <tr>
                            <td colspan="2"><input name="addcube" type="submit" value="Add Cube" /></td>
                        </tr>
                    </table>
                </form>
                <!-- End Form -->
            </div>
            <!-- End Content -->
            <!-- Footer -->
            <div class="grid_12 footer">
                <div id="footer"></div>
                </div>
            <!-- End Footer-->
        </div>
    </body>
</html>
